import http from './public'
import querystring from 'querystring'
import qs from 'qs'


/**
 * 登录认证请求
 * @param params
 * @returns {*|Promise|Promise<unknown>|Promise}
 */
export const login = params => {
  //let loginRequest = querystring.stringify(params)
  let loginRequest = qs.stringify(params);
  return http.requestPostForm('/openapi/auth/userlogin', loginRequest);
};

/**
 * 注册请求
 * @param params
 * @returns {*|Promise|Promise<unknown>|Promise}
 */
export const register = params => {
  //let loginRequest = querystring.stringify(params)
  let loginRequest = qs.stringify(params);
  return http.requestPostForm('/openapi/auth/userregister', loginRequest);
};

/**
 * 退出请求
 * @param params
 * @returns {*|Promise|Promise<unknown>|Promise}
 */
export const logout = () => {
  return http.requestPost('/openapi/auth/userlogout');
};

/**
 * 根据cookie中的令牌标识获取jwt令牌的身份内容
 * @returns {*|Promise|Promise<unknown>|Promise}
 */
export const getjwt = () => {
  return http.requestGet('/openapi/auth/userjwt');
};



